<%@page import="util.enviaEmail"%>
<%@page import="dao.funcionarioDao"%><%@
page import="bean.funcionarioBean"%><%@
page import="java.sql.Connection"%><%@
page import="conexao.Conexao"%><%@
page import="dao.funcaoDao"%><%@
page import="bean.funcaoBean"%><%@
page import="java.util.List"%><%@
page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%><%
	
	funcionarioBean id = new funcionarioBean();
	id.setId(Integer.parseInt(request.getParameter("id")));
	
	Connection conn = null;
	try {
		conn = new Conexao().getConexao();
	} catch (Exception e) {
		new enviaEmail().enviar(e);
		out.print("falhaConexao");
		return;
	}
	funcionarioBean funcionario = new funcionarioDao().getfuncionario(conn, id);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
#divAlteraUsuario select {
	width: 170px;
	height: 25px;
}
</style>
<script>
	$(function(){
		$("#alteraCPF").mask("999/999/999-99");
		$("#alteraCPF").blur(function(){
			if($(this).val() == "___/___/___-__"){
				$(this).val("");
			}
		});	
		$("#alteraTelefone").mask("(99)9999-9999");
		$("#alteraTelefone").blur(function(){
			if($(this).val() == "(__)____-____"){
				$(this).val("");
			}
		});
		$("#alteraComissao").maskMoney({precision:1});
	});	
</script>
</head>
<body>
	<div id="divAlteraUsuario">
		<p id="mensagemAlterarUsuario">Por favor informe os dados do
			Usuário.</p>
		<form id="formAlterarUsuario" class="form">
		<input type="hidden" name="id" value="<%=funcionario.getId()%>"> 
			<table border="0" cellpadding="2" cellspacing="1">
				<tr>
					<td colspan="2">Nome<br /> <input type="text" value="<%=funcionario.getNome()%>"
						id="alteraNome" name="alteraNome"
						class="text ui-widget-content ui-corner-all" size="66">
					</td>
				</tr>
				<tr>
					<td>
						Comissão (ex.: 0.5)<br /> <input type="text" value="<%=funcionario.getComissao()%>"
						id="alteraComissao" name="alteraComissao" maxlength="5"
						class="text ui-widget-content ui-corner-all" size="25"><font
						size="4" style="padding-right: 13px;">%</font>
					</td>
					<td>Função<br /> <select id="selFuncao" name="selFuncao">
							<%
								List<funcaoBean> funcoes = new funcaoDao().getLista(conn);
								for (int i = 0; i < funcoes.size(); i++) {
							%>
							<option value="<%=funcoes.get(i).getId()%>"<%if(funcionario.getIdFuncao() == funcoes.get(i).getId()){%> selected="selected" <%} %>><%=funcoes.get(i).getNome()%></option>
							<%
								}
							%>
					</select></td>
				</tr>
				<tr>
					<td colspan="2">
						</td>
				</tr>
				<tr>
					<td colspan="2">
						<table cellspacing="3">
							<tr>
								<td>Login<br /> <input type="text" size="18" value="<%=funcionario.getLogin()%>"
									id="alteraLogin" name="alteraLogin" maxlength="10"
									class="text ui-widget-content ui-corner-all">
								</td>
								<td>Senha<br /> <input type="password" size="18" value="<%=funcionario.getSenha()%>"
									id="alteraSenha" name="alteraSenha" maxlength="10"
									class="text ui-widget-content ui-corner-all">
								</td>
								<td>Confirmar Senha<br /> <input type="password" size="18" value="<%=funcionario.getSenha()%>"
									id="alteraConfSenha" name="alteraConfSenha" maxlength="10"
									class="text ui-widget-content ui-corner-all">
								</td>
							</tr>

						</table></td>
				</tr>
			</table>
		</form>
	</div>
	<%conn.close(); %>
</body>
</html>